#$pageWidth  = 20.9;
#$pageHeight = 29.6;
$pageWidth  = 29.6;
$pageHeight = 20.9;
$nx= 3;
$ny= 3;
$marginLeft    = 2.2;
$marginRight  = 0.3;
$maginTop     = 1.0;
$maginBottom = 1.2;

$dx= ($pageWidth-$marginLeft-$marginRight) / $nx;
$x0= $dx/2 + $marginLeft;
$dy= ($pageHeight-$maginTop-$maginBottom) / $ny;
$y0= $dy/2 + $maginBottom;

print "maximum axis length: x=$dx cm and y=$dy cm \n";

$iPlot=0;
$iy=0;
$pageOpen = -1;
for ($i = 5; $i < 73; $i+=9) {
	$ix      = $iPlot % $nx;
	$iy      = int($iPlot / $nx);
	$ipage = int($iy / $ny);
	$iy       = $iy % $ny;
	if ($ix==0) {
		print TO_ABS "-x setAxis -a 2 -kN\n";      # turn on y axis numbering
	}
	else {
		print TO_ABS "-x setAxis -a 2 -kY\n";      # turn off y axis numbering
	}
	if ($iy==0) {
		print TO_ABS "-x setAxis -a 1 -kN\n";      # turn on x axis numbering
	}
	else {
		print TO_ABS "-x setAxis -a 1 -kY\n";      # turn off x axis numbering
	}
	if ($ipage > $pageOpen) {
		if  ($pageOpen>=0) {
			print TO_ABS "-x savePDFofComposition -f /tmp/xx$pageOpen.pdf \n";
		}
		print TO_ABS "-x newComposition -X 0 -Y 0 -w $pageWidth -h $pageHeight \n";
		$pageOpen = $ipage;
	}
	print TO_ABS "-x selectCurveByIndex -i $i \n";
	if ($i>30 && $i<37) {
		$i9 = $i +5*9;
		print TO_ABS "-x selectCurveByIndex -i $i9 -aY \n";
	}
	print TO_ABS "-x setAttributes2 -m 2 -n -1\n";        # symbol x ON
	$xPos = $ix*$dx + $x0;
	$yPos = $iy*$dy + $y0;
	print TO_ABS "-x addPDFtoComposition -X $xPos -Y $yPos  \n";
	print TO_ABS "-x setAttributes2 -m -1 -n -1\n";       # symbol x OFF
	$iPlot++;
}

if  ($pageOpen>=0) {
	print TO_ABS "-x savePDFofComposition -f /tmp/xx$pageOpen.pdf \n";
	$pageOpen = -1;
};

print TO_ABS "-x setAxis -a 1 -kN\n";
print TO_ABS "-x setAxis -a 2 -kN\n"; 